/**
 * Created by dqw on 2015/12/30.
 */

//列表开始
var dtGridColumns = [
    {
        id: 'id',
        title: 'ID',
        type: 'number',
        columnClass: 'text-center width-20',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq'
    },
    {
        id: 'userId',
        title: '客户ID',
        type: 'int',
        hideQuery:true,
        'export':false,
        hideQueryType:'eq',
        hideQueryValue:$('#userId').val(),
        hide:false
    },
    {
        id: 'u.mobilePhone',
        title: '电话',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq'
    },
    {
        id: 'direction',
        title: '流向',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq',
        codeTable:{
            1:$lang.direction.payment,
            2:$lang.direction.receive
        }
    },
    {
        id: 'type',
        title: '资金变动类型',
        type: 'string',
        headerClass: 'text-left',
        columnClass: 'text-left',
        fastSort: false,
        fastQuery: false,
        fastQueryType: 'lk',
        codeTable:{
            1:$lang.accountLogType.T1,
            2:$lang.accountLogType.T2,
            3:$lang.accountLogType.T3,
            4:$lang.accountLogType.T4,
            5:$lang.accountLogType.T5,
            6:$lang.accountLogType.T6,
            7:$lang.accountLogType.T7,
            8:$lang.accountLogType.T8,
            9:$lang.accountLogType.T9,
            10:$lang.accountLogType.T10,
            11:$lang.accountLogType.T11,
            12:$lang.accountLogType.T12,
            13:$lang.accountLogType.T13,
            14:$lang.accountLogType.T14,
            15:$lang.accountLogType.T15,
            16:$lang.accountLogType.T16,
            17:$lang.accountLogType.T17,
            18:$lang.accountLogType.T18,
            19:$lang.accountLogType.T19,
            20:$lang.accountLogType.T20,
            21:$lang.accountLogType.T21,
            22:$lang.accountLogType.T22,
            23:$lang.accountLogType.T23,
        },
    },
    {
        id: 'amount',
        title: '资金变动(元)',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
    },
    {
        id: 'total',
        title: '剩余金额(元)',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
    },
    {
        id: 'createTime',
        title: '时间',
        type: 'date',
        format:'yyyy-MM-dd',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'range'
    },
];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + '/user/moneyDetails.json',
    exportFileName: '用户方案列表',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {int:["id","userId","limit","investId","tradeCredit","direction"],Timestamp:["buyTime","acceptTime","buyDealTime","eveningUpTime","sellTime","sellDealTime","settleTime","createTime"],BigDecimal:["buyPrice","sellPrice","profitCount"]}
};

var grid = $.fn.DtGrid.init(dtGridOption);
//默认查询条件
grid.fastQueryParameters = new Object();
grid.fastQueryParameters['eq_delFlag'] = 1;
grid.fastQueryParameters['eq_userId'] = $('#userId').val();
//排序
grid.sortParameter.columnId = ['asc_id'];
// grid.sortParameter.sortType = 0;
//列表结束

//操作处理开始
var OperateHandle = function () {

    function _bindEvent() {
        //模糊搜索
        $('#customSearch').click(function () {
            grid.fastQueryParameters = new Object();
            grid.fastQueryParameters['eq_delFlag'] = 1;
            grid.fastQueryParameters['eq_userId'] =$('#userId').val();
            grid.pager.startRecord = 0;
            grid.pager.nowPage = 1;
            grid.pager.recordCount = -1;
            grid.pager.pageCount = -1;
            grid.refresh(true);
        });
    }

    //外部可调用
    return {
        bindEvent: _bindEvent
    }
}();
//操作处理结束

$(function () {
    //加载列表
    grid.load();
    //页面绑定事件
    OperateHandle.bindEvent();
});